package com.mcp.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mcp.entity.Users;
import com.mcp.mapper.IUsersMapper;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class IUsersService extends ServiceImpl<IUsersMapper, Users> {
    public List<Users> getAllUsers(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        Page<Users> list =(Page<Users>) this.list();
        return list.getResult();
    }

    public List<Users> getAllUsersByUserName(String username) {
        QueryWrapper<Users> usersQueryWrapper = new QueryWrapper<>();
        usersQueryWrapper.lambda().like(Users::getUsername, username);
        return this.list(usersQueryWrapper);
    }
}
